GBML manual / Rooms

region_exited

True for one frame, the same frame as region_entered(), when the player leaves one region by arriving in another: use region_previous() to see which one was left. False in every other frame, and not true when the game starts, because nothing was left then.

Syntax

region_exited() -> bool

Returns

bool

Description

True for one frame, the same frame as region_entered, when the player leaves a region by arriving in another one. Ask region_previous which region was left and region_current which one the player is in now.

It is false in every other frame, and it is not true when the game starts: the first region the player arrives in is entered, but nothing was left.

The same house rule as region_entered applies: going into a house and coming back out into the same region is no change at all. Going to another world with world_go leaves the region in the old world and enters one in the new world, so both are true in the same frame.

In a long room cut into regions it is true in the frame the object the camera follows walks across a border into another region of the room.

Example

if (region_exited() && region_previous() == rg_crypt) {
    log_write("Out of the crypt");
}

Writes a line each time the player leaves the crypt (a region called "Crypt").

On the GBA

Leaving a house (a room that is not part of a world) and coming back out into the same region is not a change, so it is not true then. Going to another world with world_go() counts as leaving the region in the old world and entering one in the new world.

See also: region_enteredregion_previousregion_currentregion_exitWhat a region does in the game